import React from 'react'
import EventBusTest from '../../components/EventBusTest'
import eventBus from "../../utils/eventBus"

export default function ShopList() {
  const [favor,setFavor] = React.useState("篮球")
  const [fromChild,setFromChild] = React.useState()
  function changeFavor(){
    setFavor("乒乓球")
    eventBus.emit("changeFavor","乒乓球")
  }
  function getChildMsg(params){
    setFromChild(params)
  }
  return (
    <div>ShopList 喜欢{favor}<button onClick={changeFavor}>修改</button>
    <div>我是父组件：{fromChild}</div>
    <EventBusTest msg="这是父传子的数据" sendChild={getChildMsg}></EventBusTest>
    </div>
  )
}
